var express = require("express");

var app = new express();

// 用户api
var userApi = require('./api/user/index')
// 登录
var loginApi = require('./api/login/index')
// 消息api
var messageApi = require('./api/message/index')

//设置跨域访问
app.all('*', (req, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'Content-Type');
  res.header('Access-Control-Allow-Methods', '*');
  res.header('Content-Type', 'application/json;charset=utf-8');
  next();
});

// ?
app.get('/', (req, res, next) => {
  res.send(`This is an interface developed with nodejs, Let's try it, too`);
  next();
})

app.use('/user', userApi)
app.use('/login', loginApi)
app.use('/message', messageApi)

app.listen('9090')
